package utils

import (
	"fmt"
	"github.com/hibiken/asynq"
	"lz/global"
	"sync"
)

// 端口库单例

var once sync.Once
var pb *asynq.Client

// NewPortBin 初始化端口库
func NewRedis() *asynq.Client {

	once.Do(func() {
		pb = NewRedisDB()
	})
	return pb
}
func NewRedisDB() *asynq.Client {

	client := asynq.NewClient(asynq.RedisClientOpt{
		Addr:     fmt.Sprintf("%v:%s", global.ServerConfig.Redis.Host, global.ServerConfig.Redis.Port), //"127.0.0.1:6379",
		Password: global.ServerConfig.Redis.PassWord,
		DB:       global.ServerConfig.Redis.IndexDB,
	})

	return client
}
